Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tldts-core

Package Overview
Dependencies
Maintainers
1
Versions
726
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tldts-core

tldts core primitives (internal module)

  • 5.7.112
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.1M
increased by21.42%
Maintainers
1
Weekly downloads
 
Created

What is tldts-core?

The tldts-core npm package is a library for working with top-level domains (TLDs). It provides functionalities to parse, validate, and manipulate domain names, making it useful for tasks such as extracting the root domain, subdomain, and TLD from a given URL.

What are tldts-core's main functionalities?

Extract Root Domain

This feature allows you to extract the root domain from a given URL. In the example, the root domain 'example.co.uk' is extracted from the URL 'https://www.example.co.uk'.

const tldts = require('tldts-core');
const rootDomain = tldts.getDomain('https://www.example.co.uk');
console.log(rootDomain); // 'example.co.uk'

Extract Subdomain

This feature allows you to extract the subdomain from a given URL. In the example, the subdomain 'blog' is extracted from the URL 'https://blog.example.co.uk'.

const tldts = require('tldts-core');
const subdomain = tldts.getSubdomain('https://blog.example.co.uk');
console.log(subdomain); // 'blog'

Extract TLD

This feature allows you to extract the top-level domain (TLD) from a given URL. In the example, the TLD 'co.uk' is extracted from the URL 'https://www.example.co.uk'.

const tldts = require('tldts-core');
const tld = tldts.getPublicSuffix('https://www.example.co.uk');
console.log(tld); // 'co.uk'

Validate Domain

This feature allows you to validate whether a given domain is valid. In the example, the domain 'example.co.uk' is validated and returns true.

const tldts = require('tldts-core');
const isValid = tldts.isValid('example.co.uk');
console.log(isValid); // true

Other packages similar to tldts-core

FAQs

Package last updated on 19 Mar 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc